<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>添加品类</title>
		<link rel="stylesheet" type="text/css" href="/webapp/css/easyui.css">
		<link rel="stylesheet" type="text/css" href="/webapp/css/icon.css">
		<link rel="stylesheet" type="text/css" href="/webapp/css/color.css">
		<link rel="stylesheet" type="text/css" href="/webapp/css/public.css">
		<script type="text/javascript" src="/webapp/js/lib/jquery.min.js"></script>
		<script type="text/javascript" src="/webapp/js/lib/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="/webapp/js/lib/ajaxfileupload.js"></script>
		<script type="text/javascript" src="/webapp/js/common/config.js"></script>
	</head>
	<body class="easyui-layout">
		<div class="easyui-container-fluid">
			<div class="easyui-pannel" style="width: 100%;border: none;">
				<div class="nav"></div>
				<div class="easyui-panel" title="添加品类" style="width:100%;max-width:400px;padding:30px 60px;">
					<form id="ff" method="post">
						<div style="margin-bottom:20px">
							<select class="easyui-combobox" name="category" label="品类：" style="width:100%">
                  <option value="value1">电视</option>
                  <option value="value2">冰箱</option>
                  <option value="value3">空调</option>
                  <option value="value4">洗衣机</option>
                </select>
						</div>
						<div style="margin-bottom:20px">
							<input class="easyui-textbox" name="name" style="width:100%" data-options="label:'名称：',required:true">
						</div>
						<div style="margin-bottom:20px">
							<select class="easyui-combobox" name="category" label="类型：" style="width:100%">
                <option value="value1">文字</option>
                <option value="value2">布尔</option>
                <option value="value3">数字</option>
                <option value="value4">单选</option>
              </select>
						</div>
						<div style="margin-bottom:20px">
							<input class="easyui-tagbox" name="tags" style="width:100%;height:60px" data-options="label:'可选值：',multiline:true" value="冰箱,彩电">
						</div>
						<div style="margin-bottom:20px;">
			                <label class="item-label" style="display:inline-block;width:80px;">是否可选：</label>
			                
			                <input id="yes" name="require" type="radio"/>
			                <label for="yes">是</label>    
			                <input id="no" name="require" type="radio" checked="checked"/>
			                <label for="no">否</label>
						</div>
            <div style="margin-bottom:20px;">
                      <label class="item-label" style="display:inline-block;width:80px;">列表展示页：</label>
                      
                      <input id="yes" name="visibleOnList" type="radio"/>
                      <label for="yes">是</label>    
                      <input id="no" name="visibleOnList" type="radio" checked="checked"/>
                      <label for="no">否</label>
            </div>
            <div style="margin-bottom:20px">
              <input class="easyui-textbox" name="orderList" style="width:100%" data-options="label:'序号：',required:true">
            </div>
					</form>
					<div style="text-align:center;padding:5px 0">
						<a href="javascript:void(0)" class="easyui-linkbutton c8" onclick="submitForm()" style="width:80px">Submit</a>
						<a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()" style="width:80px">Clear</a>
					</div>
				</div>

			</div>
		</div>
	</body>
	<script type="text/javascript">
        var id = getQueryParameter("id");
        $(function(){
        	if(id){
        		$.ajax({
        			url:config.url +"/category",
        			type:'get',
        			data:{id:id},
        			xhrFields:{withCredentials:true},
        			success:function(data){
        				//填充表单
        			},
        			error:function(){

        			}
        		});
        	}
        });
        function submitForm(){
        	$("#ff").form("submit",{
        		onSubmit:function(){
        			var valid = $(this).form('enableValidation').form('validate');
        			if(valid){
        				var data = {};
        				$.ajax({
                    url:config.url+"/categorymetadata",
                    type:'post',
                    data:data,
                    xhrFields:{withCredentials:true},
                    beforeSend:function(){
                      window.parent.window.load();
                   },
                   complete:function(){
                      window.parent.window.disLoad();
                   },
                    success:function(data){
                         if(data.code==200){
                                $.messager.alert("提示","添加成功.");
                         }
                    },
                    error:function(data){
                         console.log(data);
                    }
                }); 
        			}
        			return false;
        		}
        	})
        }
        function clearForm(){
        	 $("#ff").form("clear");
        }
        
	</script>
</html>